package com.parsechina.hpush.broker.utils;

import com.parsechina.hpush.broker.config.MqttConstants;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufUtil;

/**
 * @author linfeng
 * @since 2016/11/23
 */
public final class ByteUtils {

    private ByteUtils() {

    }

    public static byte[] convert(ByteBuf content) {

        return ByteBufUtil.getBytes(content);
    }

    public static byte[] convert(String content) {

        return content.getBytes(MqttConstants.UTF8);
    }

    public static String payload2Str(ByteBuf content) {
        return content.toString(MqttConstants.UTF8);
    }

}
